Skip to content

feat(kueue): Add Kueue resource wrappers with RHOAI 2.25/3.5 compatibility - #2782

Open
jstourac wants to merge 1 commit into
RedHatQE:mainfrom
jstourac:kueue
Open

feat(kueue): Add Kueue resource wrappers with RHOAI 2.25/3.5 compatibility#2782
jstourac wants to merge 1 commit into
RedHatQE:mainfrom
jstourac:kueue

Conversation

@jstourac

@jstourac jstourac commented Aug 3, 2026

Copy link
Copy Markdown

Add wrapper classes for Kueue resources needed by opendatahub-tests for Kueue integration testing. All wrappers use a superset of fields from both kueue.x-k8s.io/v1beta1 (RHOAI 2.25) and v1beta2 (RHOAI 3.x) to support cross-version compatibility.

Resources added:

  • ResourceFlavor (kueue.x-k8s.io, cluster-scoped)
  • LocalQueue (kueue.x-k8s.io, namespaced)
  • ClusterQueue (kueue.x-k8s.io, cluster-scoped)
  • Workload (kueue.x-k8s.io, namespaced)
  • Kueue (components.platform.opendatahub.io, cluster-scoped) — RHOAI 2.25
  • Kueue (kueue.openshift.io, cluster-scoped) — RHOAI 3.x

Version-specific fields are documented in docstrings. The API server handles validation; no client-side version checks are performed.

Also adds KUEUE_X_K8S_IO and KUEUE_OPENSHIFT_IO constants to the ApiGroup enum and updates the schema mappings.

What this PR does / why we need it:

https://redhat.atlassian.net/browse/RHOAIENG-73662
opendatahub-io/opendatahub-tests#2142

Which issue(s) this PR fixes:
Special notes for reviewer:
Bug:

Summary by CodeRabbit

  • New Features
    • Added support for managing Kueue cluster and local queues.
    • Added support for Kueue workloads and resource flavors, including scheduling, priority, topology, and resource configuration.
    • Added support for configuring Kueue components through the OpenDataHub and Kueue operator APIs.
    • Added API group support for Kueue resources.

@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@jstourac, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 35 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 5645c608-ff2e-4604-afe1-cdcf8e448ac2

📥 Commits

Reviewing files that changed from the base of the PR and between 2414da1 and 121959a.

⛔ Files ignored due to path filters (1)
  • class_generator/schema/__resources-mappings.json.gz is excluded by !**/*.gz, !class_generator/schema/**
📒 Files selected for processing (7)
  • ocp_resources/cluster_queue.py
  • ocp_resources/kueue_components_platform_opendatahub_io.py
  • ocp_resources/kueue_kueue_openshift_io.py
  • ocp_resources/local_queue.py
  • ocp_resources/resource.py
  • ocp_resources/resource_flavor.py
  • ocp_resources/workload.py

Walkthrough

Adds generated Kueue resource wrappers for queues, workloads, resource flavors, and operator configuration. The wrappers define typed constructor fields, initialize inherited resource state, and serialize configured values into Kubernetes spec fields.

Changes

Kueue resource wrappers

Layer / File(s) Summary
Scheduling resource wrappers
ocp_resources/resource.py, ocp_resources/cluster_queue.py, ocp_resources/local_queue.py, ocp_resources/resource_flavor.py, ocp_resources/workload.py
Adds Kueue API group constants and wrappers for cluster queues, local queues, resource flavors, and workloads. Each wrapper stores typed fields and serializes configured values into Kubernetes spec fields.
Kueue operator configuration
ocp_resources/kueue_kueue_openshift_io.py
Adds the OpenShift Kueue resource. New resources require config, and supplied configuration and logging fields are serialized into spec.
OpenDataHub Kueue configuration
ocp_resources/kueue_components_platform_opendatahub_io.py
Adds the OpenDataHub Kueue resource with queue settings, developer flags, management state, and conditional spec serialization.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Suggested labels: size/XXL

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the addition of Kueue resource wrappers and their RHOAI version compatibility.
Description check ✅ Passed The description explains the purpose, resources, compatibility approach, and related references, despite some empty template sections.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Add Kueue CRD resource wrappers with cross-version (RHOAI 2.25/3.x) support

✨ Enhancement 🕐 20-40 Minutes

Grey Divider

AI Description

• Add ocp_resources wrappers for Kueue CRDs used by opendatahub-tests integration testing.
• Support both kueue.x-k8s.io v1beta1 (RHOAI 2.25) and v1beta2 (RHOAI 3.x) via superset specs.
• Extend ApiGroup enum/mappings with Kueue-related API groups (kueue.x-k8s.io, kueue.openshift.io).
Diagram

graph TD
  T["opendatahub-tests"] --> W["Kueue wrappers"] --> R["Resource base"] --> A(["Kubernetes API"])
  W --> G["ApiGroup enum"]
  W --> C["Kueue CRDs"] --> A
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Version-specific wrapper classes (v1beta1 vs v1beta2)
  • ➕ Avoids sending unsupported fields to older/newer API versions
  • ➕ Clearer contract per cluster version and easier schema validation in client code
  • ➖ More classes and selection logic for callers
  • ➖ Requires runtime version discovery and branching in tests
2. Runtime CRD schema discovery (generate/spec-validate at runtime)
  • ➕ Automatically tracks future schema changes without regenerating code
  • ➕ Could validate client-side before hitting the API server
  • ➖ More complex implementation and test runtime dependencies
  • ➖ Harder to keep deterministic behavior across environments
3. Thin generic CRD wrapper (raw dict passthrough)
  • ➕ Minimal maintenance and fastest iteration for tests
  • ➕ No need to keep typed parameters in sync
  • ➖ Less discoverability/IDE help and more error-prone call sites
  • ➖ Inconsistent usage patterns vs other ocp_resources wrappers

Recommendation: Keep the PR’s current approach (typed wrappers with a documented superset of fields and server-side validation). For integration tests spanning RHOAI 2.25 and 3.x, this provides a stable, ergonomic API with minimal branching. If future incompatibilities become frequent, consider splitting only the most divergent resources into version-specific wrappers while keeping common ones unified.

Files changed (7) +597 / -0

Enhancement (7) +597 / -0
cluster_queue.pyAdd ClusterQueue wrapper (kueue.x-k8s.io) with v1beta1/v1beta2 fields +157/-0

Add ClusterQueue wrapper (kueue.x-k8s.io) with v1beta1/v1beta2 fields

• Introduces a generated ClusterQueue Resource wrapper targeting the kueue.x-k8s.io API group. Exposes a superset of spec fields (e.g., cohort/cohortName, admissionScope) and renders them into spec in to_dict().

ocp_resources/cluster_queue.py

kueue_components_platform_opendatahub_io.pyAdd RHOAI 2.x Kueue operator CR wrapper (components.platform.opendatahub.io) +81/-0

Add RHOAI 2.x Kueue operator CR wrapper (components.platform.opendatahub.io)

• Adds a Kueue Resource wrapper for the RHOAI 2.x operator API group. Supports cross-version fields like devFlags (<=2.x) and autoCreateQueues (>=3.5) and maps them into spec when set.

ocp_resources/kueue_components_platform_opendatahub_io.py

kueue_kueue_openshift_io.pyAdd RHOAI 3.x Kueue operator CR wrapper (kueue.openshift.io) with required config +96/-0

Add RHOAI 3.x Kueue operator CR wrapper (kueue.openshift.io) with required config

• Adds a Kueue Resource wrapper for the OpenShift Kueue operator API group. Enforces spec.config as required and optionally includes log level, management state, and override fields.

ocp_resources/kueue_kueue_openshift_io.py

local_queue.pyAdd LocalQueue namespaced wrapper (kueue.x-k8s.io) +65/-0

Add LocalQueue namespaced wrapper (kueue.x-k8s.io)

• Introduces a generated NamespacedResource wrapper for LocalQueue. Supports clusterQueue reference plus v1beta2 fairSharing and stopPolicy fields and emits them into spec.

ocp_resources/local_queue.py

resource.pyExtend ApiGroup enum with Kueue API groups +2/-0

Extend ApiGroup enum with Kueue API groups

• Adds KUEUE_OPENSHIFT_IO and KUEUE_X_K8S_IO constants to Resource.ApiGroup to allow new wrapper classes to resolve api_group consistently.

ocp_resources/resource.py

resource_flavor.pyAdd ResourceFlavor wrapper (kueue.x-k8s.io) +82/-0

Add ResourceFlavor wrapper (kueue.x-k8s.io)

• Adds a generated ResourceFlavor Resource wrapper for cluster-scoped flavors. Supports nodeLabels, nodeTaints, tolerations, and topologyName and renders them into spec.

ocp_resources/resource_flavor.py

workload.pyAdd Workload namespaced wrapper with v1beta1/v1beta2 priority fields +114/-0

Add Workload namespaced wrapper with v1beta1/v1beta2 priority fields

• Introduces a generated NamespacedResource wrapper for Workload. Supports both v1beta1-style priorityClassName/priorityClassSource and v1beta2+ priorityClassRef, plus queueName/podSets and other core fields.

ocp_resources/workload.py

@qodo-code-review

qodo-code-review Bot commented Aug 3, 2026

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (1) 📘 Rule violations (2) 📜 Skill insights (0)

Context used
⚠️ Tickets: not configured — ticket URL found in PR but could not be fetched — check ticket provider credentials
✅ Compliance rules (platform): 18 rules

Grey Divider


Remediation recommended

1. Invalid ClusterQueue spec combo 🐞 Bug ≡ Correctness
Description
ClusterQueue.to_dict() can serialize both spec.admissionChecks and spec.admissionChecksStrategy when
both constructor args are provided, even though the API contract (documented in this class) says
they cannot be used together. This produces a manifest that violates the documented API constraints
and may fail server-side validation or behave unexpectedly.
Code

ocp_resources/cluster_queue.py[R122-125]

+                _spec["admissionChecks"] = self.admission_checks
+
+            if self.admission_checks_strategy is not None:
+                _spec["admissionChecksStrategy"] = self.admission_checks_strategy
Relevance

●● Moderate

No clear historical evidence on enforcing mutual exclusivity between spec fields during
serialization in wrappers.

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The class docstring explicitly states that admissionChecks cannot be used with
AdmissionCheckStrategy, yet to_dict writes both fields independently when both attributes are
non-None.

ocp_resources/cluster_queue.py[33-36]
ocp_resources/cluster_queue.py[121-125]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`ClusterQueue` documents that `admissionChecks` cannot be used together with `admissionCheckStrategy`, but the wrapper currently allows both inputs and will emit both fields in `spec` when both are set.

### Issue Context
This is a newly added generated wrapper; adding a small guard is consistent with other resources in this repo that raise early (e.g., `MissingRequiredArgumentError`) when required/invalid combinations are detected.

### Fix Focus Areas
- ocp_resources/cluster_queue.py[16-36]
- ocp_resources/cluster_queue.py[113-126]

### Suggested fix
Add a guard in `__init__` or `to_dict` such as:

```python
if self.admission_checks is not None and self.admission_checks_strategy is not None:
   raise ValueError("admission_checks and admission_checks_strategy are mutually exclusive")
```

(Optionally use `MissingRequiredArgumentError` or a new dedicated exception if that’s preferred in this codebase.)

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Informational

2. __init__ docstring missing summary 📘 Rule violation ⚙ Maintainability
Description
New __init__ docstrings start immediately with Args: and omit the required one-line summary
sentence ending with a period. This breaks the required Google-style docstring format.
Code

ocp_resources/cluster_queue.py[R32-35]

+        r"""
+        Args:
+            admission_checks (list[Any]): admissionChecks lists the AdmissionChecks required by this
+              ClusterQueue. Cannot be used along with AdmissionCheckStrategy.
Relevance

● Weak

Similar Google-style docstring formatting change was rejected in PR #2765; generated wrappers keep
Args-first docstrings.

PR-#2765

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 1834792 requires Google-style docstrings with a one-line summary sentence ending
with a period. The new __init__ docstrings begin with Args: and provide no summary line.

Rule 1834792: Inline docstrings must use Google-style triple-quoted blocks
ocp_resources/cluster_queue.py[32-36]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Several newly added `__init__` docstrings omit the required one-line summary (capitalized and ending with a period) and begin directly with `Args:`.

## Issue Context
The compliance rule requires Google-style docstrings with a summary line, optional blank line, then sections like `Args:`.

## Fix Focus Areas
- ocp_resources/cluster_queue.py[32-41]
- ocp_resources/local_queue.py[23-31]
- ocp_resources/workload.py[28-36]
- ocp_resources/kueue_components_platform_opendatahub_io.py[25-33]
- ocp_resources/kueue_kueue_openshift_io.py[27-35]
- ocp_resources/resource_flavor.py[24-31]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


3. Kueue.to_dict() raises on config ✓ Resolved 📘 Rule violation ≡ Correctness
Description
to_dict() performs client-side validation by raising MissingRequiredArgumentError when
self.config is None. This violates the requirement that to_dict() only serialize fields and
not enforce resource validity.
Code

ocp_resources/kueue_kueue_openshift_io.py[R72-75]

+        if not self.kind_dict and not self.yaml_file:
+            if self.config is None:
+                raise MissingRequiredArgumentError(argument="self.config")
+
Relevance

● Weak

Repo commonly allows MissingRequiredArgumentError validation in to_dict(); similar patterns shipped
in PR #2520/#2542.

PR-#2520
PR-#2542

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 1835318 forbids validation logic inside to_dict(). The new Kueue.to_dict()
explicitly checks self.config and raises an exception instead of purely serializing fields.

Rule 1835318: to_dict() must only serialize fields and must not perform resource validation
ocp_resources/kueue_kueue_openshift_io.py[72-75]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`ocp_resources/kueue_kueue_openshift_io.py` performs validation inside `to_dict()` by raising `MissingRequiredArgumentError` when `config` is missing. The compliance rule requires `to_dict()` to be pure serialization only.

## Issue Context
If `config` is required, enforce this outside `to_dict()` (e.g., make `config` a required `__init__` parameter, or add a separate `validate()` method invoked by create/update paths).

## Fix Focus Areas
- ocp_resources/kueue_kueue_openshift_io.py[17-26]
- ocp_resources/kueue_kueue_openshift_io.py[68-80]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


4. to_dict() returns None 📘 Rule violation ⚙ Maintainability
Description
New resource wrapper to_dict() methods are annotated as returning None and do not return a
dictionary value. This violates the requirement that resource to_dict() methods return a dict.
Code

ocp_resources/cluster_queue.py[R113-116]

+    def to_dict(self) -> None:
+
+        super().to_dict()
+
Relevance

● Weak

Team explicitly rejected changing to_dict() to return dict; PR #2765 kept `def to_dict(self) ->
None`.

PR-#2765

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 1834979 requires resource classes to define to_dict(self) -> dict and return a
dictionary. The new ClusterQueue.to_dict() is defined as returning None and has no return
statement producing a dict.

Rule 1834979: Resource classes must define init and to_dict methods
ocp_resources/cluster_queue.py[113-118]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The newly added wrapper `to_dict()` methods are declared as `-> None` and do not return a dict object.

## Issue Context
The compliance rule requires `to_dict(self) -> dict` and that the method actually returns a dictionary.

## Fix Focus Areas
- ocp_resources/cluster_queue.py[113-157]
- ocp_resources/local_queue.py[48-65]
- ocp_resources/workload.py[82-114]
- ocp_resources/resource_flavor.py[62-82]
- ocp_resources/kueue_components_platform_opendatahub_io.py[58-81]
- ocp_resources/kueue_kueue_openshift_io.py[68-96]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

To customize comments, go to the Qodo configuration screen, or learn more in the docs.

Qodo Logo

Comment on lines +122 to +125
_spec["admissionChecks"] = self.admission_checks

if self.admission_checks_strategy is not None:
_spec["admissionChecksStrategy"] = self.admission_checks_strategy

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remediation recommended

4. Invalid clusterqueue spec combo 🐞 Bug ≡ Correctness

ClusterQueue.to_dict() can serialize both spec.admissionChecks and spec.admissionChecksStrategy when
both constructor args are provided, even though the API contract (documented in this class) says
they cannot be used together. This produces a manifest that violates the documented API constraints
and may fail server-side validation or behave unexpectedly.
Agent Prompt
### Issue description
`ClusterQueue` documents that `admissionChecks` cannot be used together with `admissionCheckStrategy`, but the wrapper currently allows both inputs and will emit both fields in `spec` when both are set.

### Issue Context
This is a newly added generated wrapper; adding a small guard is consistent with other resources in this repo that raise early (e.g., `MissingRequiredArgumentError`) when required/invalid combinations are detected.

### Fix Focus Areas
- ocp_resources/cluster_queue.py[16-36]
- ocp_resources/cluster_queue.py[113-126]

### Suggested fix
Add a guard in `__init__` or `to_dict` such as:

```python
if self.admission_checks is not None and self.admission_checks_strategy is not None:
    raise ValueError("admission_checks and admission_checks_strategy are mutually exclusive")
```

(Optionally use `MissingRequiredArgumentError` or a new dedicated exception if that’s preferred in this codebase.)

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be addressed already

…ility

Add wrapper classes for Kueue resources needed by opendatahub-tests
for Kueue integration testing. All wrappers use a superset of fields
from both kueue.x-k8s.io/v1beta1 (RHOAI 2.25) and v1beta2 (RHOAI 3.x)
to support cross-version compatibility.

Resources added:
- ResourceFlavor (kueue.x-k8s.io, cluster-scoped)
- LocalQueue (kueue.x-k8s.io, namespaced)
- ClusterQueue (kueue.x-k8s.io, cluster-scoped)
- Workload (kueue.x-k8s.io, namespaced)
- Kueue (components.platform.opendatahub.io, cluster-scoped) — RHOAI 2.25
- Kueue (kueue.openshift.io, cluster-scoped) — RHOAI 3.x

Version-specific fields are documented in docstrings. The API server
handles validation; no client-side version checks are performed.

Also adds KUEUE_X_K8S_IO and KUEUE_OPENSHIFT_IO constants to the
ApiGroup enum and updates the schema mappings.

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants